package com.zfl;

public class IsSymmetric {
    public boolean isSymmetric(TreeNode root) {
        return isMirror(root.left,root.right);
    }

    private boolean isMirror(TreeNode left, TreeNode right) {
        if (left==null&&right==null)
            return true;
        if (left==null||right==null)
            return false;
        if (left.val!=right.val)
            return false;

        boolean flag1 = this.isMirror(left.left, right.right);
        boolean flag2 = this.isMirror(left.right, right.left);

        return flag1&&flag2;
    }
}
